Custom Targeting Key
Update a custom targeting key
Updates a custom targeting key. Only the owner or an admin may update.
PATCH
/
api
/
manager
/
custom-targeting
/
keys
/
{code}
Update a custom targeting key
curl --request PATCH \
--url https://your_a2_service/api/manager/custom-targeting/keys/{code} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"display_name": "Gender (updated)",
"visibility": "private"
}
'import requests
url = "https://your_a2_service/api/manager/custom-targeting/keys/{code}"
payload = {
"display_name": "Gender (updated)",
"visibility": "private"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({display_name: 'Gender (updated)', visibility: 'private'})
};
fetch('https://your_a2_service/api/manager/custom-targeting/keys/{code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your_a2_service/api/manager/custom-targeting/keys/{code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Gender (updated)',
'visibility' => 'private'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your_a2_service/api/manager/custom-targeting/keys/{code}"
payload := strings.NewReader("{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://your_a2_service/api/manager/custom-targeting/keys/{code}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your_a2_service/api/manager/custom-targeting/keys/{code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"display_name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "predefined",
"updated_at": "2023-11-07T05:31:56Z",
"deprecated": false,
"description": "<string>",
"ext": "<unknown>",
"no": 123,
"value_count": 0,
"visibility": "public"
}{
"detail": {
"code": "AUTH.UNAUTHORIZED",
"message": "Authentication is required."
}
}{
"detail": {
"code": "AUTH.NO_PERMISSION",
"message": "do not have permission to perform this action."
}
}{
"detail": {
"code": "CUSTOM_TARGETING.NOT_FOUND",
"message": "Custom targeting key not found."
}
}{
"detail": {
"code": "CUSTOM_TARGETING.KEY_IN_USE_BY_SEGMENT",
"message": "This property cannot be made private while it is used by a segment."
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication. Pass the access token in the Authorization: Bearer <token> header.
Path Parameters
Body
application/json
Response
Successful Response
Required string length:
1 - 32Pattern:
^[a-z][a-z0-9._-]{0,31}$Required string length:
1 - 100Available options:
predefined, freeform Available options:
public, private Was this page helpful?
⌘I
Update a custom targeting key
curl --request PATCH \
--url https://your_a2_service/api/manager/custom-targeting/keys/{code} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"display_name": "Gender (updated)",
"visibility": "private"
}
'import requests
url = "https://your_a2_service/api/manager/custom-targeting/keys/{code}"
payload = {
"display_name": "Gender (updated)",
"visibility": "private"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({display_name: 'Gender (updated)', visibility: 'private'})
};
fetch('https://your_a2_service/api/manager/custom-targeting/keys/{code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your_a2_service/api/manager/custom-targeting/keys/{code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Gender (updated)',
'visibility' => 'private'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your_a2_service/api/manager/custom-targeting/keys/{code}"
payload := strings.NewReader("{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://your_a2_service/api/manager/custom-targeting/keys/{code}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your_a2_service/api/manager/custom-targeting/keys/{code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Gender (updated)\",\n \"visibility\": \"private\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"display_name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "predefined",
"updated_at": "2023-11-07T05:31:56Z",
"deprecated": false,
"description": "<string>",
"ext": "<unknown>",
"no": 123,
"value_count": 0,
"visibility": "public"
}{
"detail": {
"code": "AUTH.UNAUTHORIZED",
"message": "Authentication is required."
}
}{
"detail": {
"code": "AUTH.NO_PERMISSION",
"message": "do not have permission to perform this action."
}
}{
"detail": {
"code": "CUSTOM_TARGETING.NOT_FOUND",
"message": "Custom targeting key not found."
}
}{
"detail": {
"code": "CUSTOM_TARGETING.KEY_IN_USE_BY_SEGMENT",
"message": "This property cannot be made private while it is used by a segment."
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}